Add support for caching Memory Reference Code data
Subsystems (5)
v3 cover Add support for caching Memory Reference Code data
Since the memory reference code is so slow on x86, add a feature to bypass this, storing the previous parameters in SPI flash. This saves around 500ms on each boot.
Also enable a SPI flash environment.
Changes in v3:
- Add new patch to move checksum to its own file in net/
- Adjust net/ code to use the new checksum functions
- Use checksum code that is now in net/checksum.c
- Adjust functions to remain compatible with other RTC drivers
- Drop accidental creation of link.dts due to bad rebase
- Use checksum code from net/checksum.c
- Add misc_init_r() call for link now that it is shared with chromebook_link
Changes in v2:
- Use intel,ich-spi as the compatible string
- Refactor IP checksum patches
- Adjust the mc146818 driver instead of adding a new cmos.h header
- Make changes to chromebook_link.dts since link.dts is gone
- Use intel,ich-spi as the compatible string
- Update for the new CMOS RAM access functions in the RTC
- Add a comment about why both CMOS RAM and SPI flash are used for the cache
Simon Glass (12):
x86: dts: Add compatible string for Intel ICH9 SPI controller
net: Add a separate file for IP checksumming
net: Use new checksum functions
x86: Use ipchecksum from net/
x86: rtc: mc146818: Add helpers to read/write CMOS RAM
x86: spi: Add device tree support
Allow architecture-specific memory reservation
x86: dts: Add SPI flash MRC details for chromebook_link
x86: Implement a cache for Memory Reference Code parameters
x86: config: Enable hook for saving MRC configuration
x86: ivybridge: Drop the Kconfig MRC cache information
x86: config: chromebook_link: Enable environment
arch/x86/cpu/coreboot/Makefile | 1 - arch/x86/cpu/coreboot/coreboot.c | 5 + arch/x86/cpu/coreboot/ipchecksum.c | 55 ------ arch/x86/cpu/coreboot/tables.c | 8 +- arch/x86/cpu/ivybridge/Kconfig | 28 --- arch/x86/cpu/ivybridge/Makefile | 1 + arch/x86/cpu/ivybridge/mrccache.c | 156 +++++++++++++++ arch/x86/cpu/ivybridge/sdram.c | 253 ++++++++++++++++++++++++ arch/x86/dts/chromebook_link.dts | 15 +- arch/x86/include/asm/arch-coreboot/ipchecksum.h | 37 ---- arch/x86/include/asm/arch-ivybridge/mrccache.h | 51 +++++ arch/x86/include/asm/global_data.h | 3 + common/board_f.c | 7 + drivers/rtc/mc146818.c | 121 +++++++----- drivers/spi/ich.c | 7 + include/configs/chromebook_link.h | 8 + include/configs/x86-common.h | 1 + include/fdtdec.h | 1 + include/net.h | 32 ++- include/rtc.h | 32 +++ lib/fdtdec.c | 1 + net/Makefile | 1 + net/checksum.c | 60 ++++++ net/net.c | 25 +-- net/ping.c | 10 +- 25 files changed, 713 insertions(+), 206 deletions(-) delete mode 100644 arch/x86/cpu/coreboot/ipchecksum.c create mode 100644 arch/x86/cpu/ivybridge/mrccache.c delete mode 100644 arch/x86/include/asm/arch-coreboot/ipchecksum.h create mode 100644 arch/x86/include/asm/arch-ivybridge/mrccache.h create mode 100644 net/checksum.c
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 1/12 x86: dts: Add compatible string for Intel ICH9 SPI controller
Add this to the enum so that we can use the various fdtdec functions. A later commit will move this driver to driver model.
---
Changes in v3: None
Changes in v2:
- Use intel,ich-spi as the compatible string
include/fdtdec.h | 1 + lib/fdtdec.c | 1 + 2 files changed, 2 insertions(+)
include/fdtdec.h +1 -0
@@ -173,6 +173,7 @@ enum fdt_compat_id {COMPAT_INTEL_MODEL_206AX ,/* Intel Model 206AX CPU */ COMPAT_INTEL_GMA ,/* Intel Graphics Media Accelerator */ COMPAT_AMS_AS3722 ,/* AMS AS3722 PMIC */ +COMPAT_INTEL_ICH_SPI ,/* Intel ICH7/9 SPI controller */ COMPAT_COUNT, };
lib/fdtdec.c +1 -0
@@ -83,6 +83,7 @@ static const char * const compat_names[COMPAT_COUNT] = {COMPAT (INTEL_MODEL_206AX ,"intel,model-206ax" ),COMPAT (INTEL_GMA ,"intel,gma" ),COMPAT (AMS_AS3722 ,"ams,as3722" ), + COMPAT(INTEL_ICH_SPI, "intel,ich-spi"), };const char *fdtdec_get_compatible (enum fdt_compat_id id)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 1/12 x86: dts: Add compatible string for Intel ICH9 SPI controller
Quoted 6 lines · Simon Glass
Add this to the enum so that we can use the various fdtdec functions. A later commit will move this driver to driver model.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Changes in v3: None
Changes in v2:
- Use intel,ich-spi as the compatible stringinclude/fdtdec.h | 1 + lib/fdtdec.c | 1 + 2 files changed, 2 insertions(+)
Applied to u-boot-x86.
PATCH v3 2/12 net: Add a separate file for IP checksumming
In reply to Simon GlassMove the checksum code out into its own file so it can be used elsewhere. Also use a new version which supports a length which is not a multiple of 2 and add a new function to add two checksums.
---
Changes in v3:
- Add new patch to move checksum to its own file in net/
Changes in v2: None
include/net.h | 30 +++++++++++++++++++++++++++++ net/Makefile | 1 + net/checksum.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 net/checksum.c
include/net.h +30 -0
@@ -482,6 +482,36 @@ extern void net_set_ip_header(uchar *pkt, IPaddr_t dest, IPaddr_t source);extern void net_set_udp_header (uchar *pkt,IPaddr_t dest,int dport,int sport,int len); +/** +* compute_ip_checksum() - Compute IP checksum +* +* @addr: Address to check (must be 16-bit aligned) +* @nbytes: Number of bytes to check (normally a multiple of 2) +* @return 16-bit IP checksum +*/ +unsigned compute_ip_checksum (const void *addr,unsigned nbytes); + +/** +* add_ip_checksums() - add two IP checksums +* +* @offset: Offset of first sum (if odd we do a byte-swap) +* @sum: First checksum +* @new_sum: New checksum to add +* @return updated 16-bit IP checksum +*/ +unsigned add_ip_checksums (unsigned offset,unsigned sum,unsigned new_sum); + +/** +* ip_checksum_ok() - check if a checksum is correct +* +* This works by making sure the checksum sums to 0 +* +* @addr: Address to check (must be 16-bit aligned) +* @nbytes: Number of bytes to check (normally a multiple of 2) +* @return true if the checksum matches, false if not +*/ +int ip_checksum_ok (const void *addr,unsigned nbytes); +/* Checksum */ extern int NetCksumOk (uchar *,int );/* Return true if cksum OK */ extern uint NetCksum (uchar *,int );/* Calculate the checksum */
net/Makefile +1 -0
@@ -7,6 +7,7 @@ #ccflags-y += -DDEBUG +obj-y += checksum.o obj-$(CONFIG_CMD_NET) += arp.o obj-$(CONFIG_CMD_NET) += bootp.o obj-$(CONFIG_CMD_CDP) += cdp.o
net/checksum.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 2/12 net: Add a separate file for IP checksumming
Quoted 10 lines · Simon Glass
Move the checksum code out into its own file so it can be used elsewhere. Also use a new version which supports a length which is not a multiple of 2 and add a new function to add two checksums.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add new patch to move checksum to its own file innet/
Quoted 7 lines
Changes in v2: None
include/net.h | 30 +++++++++++++++++++++++++++++ net/Makefile | 1 + net/checksum.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 net/checksum.c
Applied to u-boot-x86.
PATCH v3 3/12 net: Use new checksum functions
In reply to Simon GlassDrop the old checksum functions in favour of the new ones.
---
Changes in v3:
- Adjust net/ code to use the new checksum functions
Changes in v2: None
include/net.h | 4 ---- net/net.c | 25 ++----------------------- net/ping.c | 10 ++++------ 3 files changed, 6 insertions(+), 33 deletions(-)
include/net.h +0 -4
@@ -512,10 +512,6 @@ unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned new_sum);*/ int ip_checksum_ok (const void *addr,unsigned nbytes); -/* Checksum */ -extern int NetCksumOk (uchar *,int );/* Return true if cksum OK */ -extern uint NetCksum (uchar *,int );/* Calculate the checksum */ -/* Callbacks */ extern rxhand_f *net_get_udp_handler (void );/* Get UDP RX packet handler */ extern void net_set_udp_handler (rxhand_f *);/* Set UDP RX packet handler */
net/net.c +2 -23
@@ -1086,7 +1086,7 @@ NetReceive(uchar *inpkt, int len)if ((ip->ip_hl_v &0x0f ) >0x05 )return ;/* Check the Checksum of the header */ -if (!NetCksumOk ((uchar *)ip,IP_HDR_SIZE /2 )) { +if (!ip_checksum_ok ((uchar *)ip,IP_HDR_SIZE )) {debug ("checksum bad\n" );return ; }
@@ -1291,27 +1291,6 @@ common:/**********************************************************************/ int -NetCksumOk (uchar *ptr,int len) -{ -return !((NetCksum (ptr, len) +1 ) &0xfffe ); -} - - -unsigned -NetCksum (uchar *ptr,int len) -{ -ulong xsum; -ushort *p = (ushort *)ptr; - - xsum =0 ; -while (len-- >0 ) - xsum += *p++; - xsum = (xsum &0xffff ) + (xsum >>16 ); - xsum = (xsum &0xffff ) + (xsum >>16 ); -return xsum &0xffff ; -} - -int NetEthHdrSize (void ) {ushort myvlanid;
@@ -1410,7 +1389,7 @@ void net_set_udp_header(uchar *pkt, IPaddr_t dest, int dport, int sport,net_set_ip_header (pkt, dest, NetOurIP); ip->ip_len =htons (IP_UDP_HDR_SIZE + len); ip->ip_p =IPPROTO_UDP ; - ip->ip_sum = ~NetCksum ((uchar *)ip,IP_HDR_SIZE >>1 ); + ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); ip->udp_src =htons (sport); ip->udp_dst =htons (dport);
net/ping.c +4 -6
@@ -29,14 +29,14 @@ static void set_icmp_header(uchar *pkt, IPaddr_t dest) ip->ip_len =htons (IP_ICMP_HDR_SIZE ); ip->ip_p =IPPROTO_ICMP ; - ip->ip_sum = ~NetCksum ((uchar *)ip,IP_HDR_SIZE >>1 ); + ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); icmp->type =ICMP_ECHO_REQUEST ; icmp->code =0 ; icmp->checksum =0 ; icmp->un.echo.id =0 ; icmp->un.echo.sequence =htons (PingSeqNo++); - icmp->checksum = ~NetCksum ((uchar *)icmp,ICMP_HDR_SIZE >>1 ); + icmp->checksum =compute_ip_checksum (icmp,ICMP_HDR_SIZE ); }static int ping_send (void )
@@ -101,13 +101,11 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) ip->ip_off =0 ;NetCopyIP ((void *)&ip->ip_dst, &ip->ip_src);NetCopyIP ((void *)&ip->ip_src, &NetOurIP); - ip->ip_sum = ~NetCksum ((uchar *)ip, -IP_HDR_SIZE >>1 ); + ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); icmph->type =ICMP_ECHO_REPLY ; icmph->checksum =0 ; - icmph->checksum = ~NetCksum ((uchar *)icmph, - (len -IP_HDR_SIZE ) >>1 ); + icmph->checksum =compute_ip_checksum (icmph, len -IP_HDR_SIZE );NetSendPacket ((uchar *)et, eth_hdr_size + len);return ;/* default:
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 3/12 net: Use new checksum functions
Quoted 4 lines · Simon Glass
Drop the old checksum functions in favour of the new ones.
Signed-off-by Simon Glass <[email protected]>
Looks good to me.
Thanks!
-Joe
PATCH v3 3/12 net: Use new checksum functions
Quoted 4 lines · Joe Hershberger
Quoted 3 lines · Simon Glass
Drop the old checksum functions in favour of the new ones.
Quoted 8 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>Looks good to me.
Acked-by Joe Hershberger <[email protected]>Thanks!
-Joe
Applied to u-boot-dm.
PATCH v3 4/12 x86: Use ipchecksum from net/
In reply to Simon GlassThe existing IP checksum function is only accessible to the 'coreboot' cpu. Drop it in favour of the new code in the network subsystem.
---
Changes in v3:
- Use checksum code that is now in net/checksum.c
Changes in v2:
- Refactor IP checksum patches
arch/x86/cpu/coreboot/Makefile | 1 - arch/x86/cpu/coreboot/ipchecksum.c | 55 ------------------------- arch/x86/cpu/coreboot/tables.c | 8 ++-- arch/x86/include/asm/arch-coreboot/ipchecksum.h | 37 ----------------- 4 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 arch/x86/cpu/coreboot/ipchecksum.c delete mode 100644 arch/x86/include/asm/arch-coreboot/ipchecksum.h
arch/x86/cpu/coreboot/Makefile +0 -1
@@ -16,7 +16,6 @@ obj-y += car.o obj-y += coreboot.o obj-y += tables.o -obj-y += ipchecksum.o obj-y += sdram.o obj-y += timestamp.o obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/coreboot/ipchecksum.c deleted +0 -55
55 lines not on this page · raw message
arch/x86/cpu/coreboot/tables.c +4 -4
@@ -8,7 +8,7 @@*/ #include <common.h> -#include <asm/arch/ipchecksum.h> +#include <net.h> #include <asm/arch/sysinfo.h> #include <asm/arch/tables.h>
@@ -131,11 +131,11 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)return 0 ;/* Make sure the checksums match. */ -if (ipchksum ((u16 *) header,sizeof (*header)) !=0 ) +if (!ip_checksum_ok (header,sizeof (*header)))return -1 ; -if (ipchksum ((u16 *) (ptr +sizeof (*header)), - header->table_bytes) != header->table_checksum) +if (compute_ip_checksum (ptr +sizeof (*header), header->table_bytes) != + header->table_checksum)return -1 ;/* Now, walk the tables. */
arch/x86/include/asm/arch-coreboot/ipchecksum.h deleted +0 -37
@@ -1,37 +0,0 @@ -/* -* This file is part of the libpayload project. -* -* It has originally been taken from the FreeBSD project. -* -* Copyright (c) 2001 Charles Mott <[email protected]> -* Copyright (c) 2008 coresystems GmbH -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -* SUCH DAMAGE. -*/ - -#ifndef _COREBOOT_IPCHECKSUM_H -#define _COREBOOT_IPCHECKSUM_H - -unsigned short ipchksum (const void *vptr,unsigned long nbytes); - -#endif
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 4/12 x86: Use ipchecksum from net/
Quoted 12 lines · Simon Glass
The existing IP checksum function is only accessible to the 'coreboot' cpu. Drop it in favour of the new code in the network subsystem.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Use checksum code that is now innet/checksum.cChanges in v2:
- Refactor IP checksum patches
Quoted 7 lines
arch/x86/cpu/coreboot/Makefile | 1 - arch/x86/cpu/coreboot/ipchecksum.c | 55 ------------------------- arch/x86/cpu/coreboot/tables.c | 8 ++-- arch/x86/include/asm/arch-coreboot/ipchecksum.h | 37 ----------------- 4 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 arch/x86/cpu/coreboot/ipchecksum.c delete mode 100644 arch/x86/include/asm/arch-coreboot/ipchecksum.h
Applied to u-boot-x86.
PATCH v3 5/12 x86: rtc: mc146818: Add helpers to read/write CMOS RAM
In reply to Simon GlassOn x86 we use CMOS RAM to read and write some settings. Add basic support for this, including access to registers 128-255.
---
Changes in v3:
- Adjust functions to remain compatible with other RTC drivers
Changes in v2:
- Adjust the mc146818 driver instead of adding a new cmos.h header
drivers/rtc/mc146818.c | 121 +++++++++++++++++++++++++++++-------------------- include/rtc.h | 32 +++++++++++++ 2 files changed, 105 insertions(+), 48 deletions(-)
drivers/rtc/mc146818.c +73 -48
@@ -27,9 +27,6 @@/* Set this to 1 to clear the CMOS RAM */ #define CLEAR_CMOS 0 -static uchar rtc_read (uchar reg); -static void rtc_write (uchar reg,uchar val); -#define RTC_PORT_MC146818 CONFIG_SYS_ISA_IO_BASE_ADDRESS + 0x70#define RTC_SECONDS 0x00#define RTC_SECONDS_ALARM 0x01
@@ -60,24 +57,24 @@ int rtc_get (struct rtc_time *tmp) {uchar sec, min, hour, mday, wday, mon, year;/* here check if rtc can be accessed */ -while ((rtc_read (RTC_CONFIG_A )&0x80 )==0x80 ); - sec =rtc_read (RTC_SECONDS ); - min =rtc_read (RTC_MINUTES ); - hour =rtc_read (RTC_HOURS ); - mday =rtc_read (RTC_DATE_OF_MONTH ); - wday =rtc_read (RTC_DAY_OF_WEEK ); - mon =rtc_read (RTC_MONTH ); - year =rtc_read (RTC_YEAR ); +while ((rtc_read8 (RTC_CONFIG_A ) &0x80 ) ==0x80 ); + sec =rtc_read8 (RTC_SECONDS ); + min =rtc_read8 (RTC_MINUTES ); + hour =rtc_read8 (RTC_HOURS ); + mday =rtc_read8 (RTC_DATE_OF_MONTH ); + wday =rtc_read8 (RTC_DAY_OF_WEEK ); + mon =rtc_read8 (RTC_MONTH ); + year =rtc_read8 (RTC_YEAR );#ifdef RTC_DEBUG printf ("Get RTC year: %02x mon/cent: %02x mday: %02x wday: %02x " "hr: %02x min: %02x sec: %02x\n" , year, mon, mday, wday, hour, min, sec );printf ("Alarms: month: %02x hour: %02x min: %02x sec: %02x\n" , -rtc_read (RTC_CONFIG_D ) &0x3F , -rtc_read (RTC_HOURS_ALARM ), -rtc_read (RTC_MINUTES_ALARM ), -rtc_read (RTC_SECONDS_ALARM ) ); +rtc_read8 (RTC_CONFIG_D ) &0x3F , +rtc_read8 (RTC_HOURS_ALARM ), +rtc_read8 (RTC_MINUTES_ALARM ), +rtc_read8 (RTC_SECONDS_ALARM ));#endif tmp->tm_sec =bcd2bin (sec &0x7F ); tmp->tm_min =bcd2bin (min &0x7F );
@@ -108,80 +105,108 @@ int rtc_set (struct rtc_time *tmp) tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);#endif -rtc_write (RTC_CONFIG_B ,0x82 );/* disables the RTC to update the regs */ +rtc_write8 (RTC_CONFIG_B ,0x82 );/* disable the RTC to update the regs */ -rtc_write (RTC_YEAR ,bin2bcd (tmp->tm_year %100 )); -rtc_write (RTC_MONTH ,bin2bcd (tmp->tm_mon)); -rtc_write (RTC_DAY_OF_WEEK ,bin2bcd (tmp->tm_wday)); -rtc_write (RTC_DATE_OF_MONTH ,bin2bcd (tmp->tm_mday)); -rtc_write (RTC_HOURS ,bin2bcd (tmp->tm_hour)); -rtc_write (RTC_MINUTES ,bin2bcd (tmp->tm_min )); -rtc_write (RTC_SECONDS ,bin2bcd (tmp->tm_sec )); -rtc_write (RTC_CONFIG_B ,0x02 );/* enables the RTC to update the regs */ +rtc_write8 (RTC_YEAR ,bin2bcd (tmp->tm_year %100 )); +rtc_write8 (RTC_MONTH ,bin2bcd (tmp->tm_mon)); +rtc_write8 (RTC_DAY_OF_WEEK ,bin2bcd (tmp->tm_wday)); +rtc_write8 (RTC_DATE_OF_MONTH ,bin2bcd (tmp->tm_mday)); +rtc_write8 (RTC_HOURS ,bin2bcd (tmp->tm_hour)); +rtc_write8 (RTC_MINUTES ,bin2bcd (tmp->tm_min)); +rtc_write8 (RTC_SECONDS ,bin2bcd (tmp->tm_sec)); +rtc_write8 (RTC_CONFIG_B ,0x02 );/* enable the RTC to update the regs */ return 0 ; }void rtc_reset (void ) { -rtc_write (RTC_CONFIG_B ,0x82 );/* disables the RTC to update the regs */ -rtc_write (RTC_CONFIG_A ,0x20 );/* Normal OP */ -rtc_write (RTC_CONFIG_B ,0x00 ); -rtc_write (RTC_CONFIG_B ,0x00 ); -rtc_write (RTC_CONFIG_B ,0x02 );/* enables the RTC to update the regs */ +rtc_write8 (RTC_CONFIG_B ,0x82 );/* disable the RTC to update the regs */ +rtc_write8 (RTC_CONFIG_A ,0x20 );/* Normal OP */ +rtc_write8 (RTC_CONFIG_B ,0x00 ); +rtc_write8 (RTC_CONFIG_B ,0x00 ); +rtc_write8 (RTC_CONFIG_B ,0x02 );/* enable the RTC to update the regs */ }/* ------------------------------------------------------------------------- */ -#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR /* * use direct memory access */ -static uchar rtc_read (uchar reg) +int rtc_read8 (int reg) { +#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR return in8 (CONFIG_SYS_RTC_REG_BASE_ADDR + reg); +#else +int ofs =0 ; + +if (reg >=128 ) { + ofs =2 ; + reg -=128 ; + } +out8 (RTC_PORT_MC146818 + ofs, reg); + +return in8 (RTC_PORT_MC146818 + ofs +1 ); +#endif } -static void rtc_write (uchar reg,uchar val) +void rtc_write8 (int reg,uchar val) { +#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR out8 (CONFIG_SYS_RTC_REG_BASE_ADDR + reg, val); -}#else -static uchar rtc_read (uchar reg) +int ofs =0 ; + +if (reg >=128 ) { + ofs =2 ; + reg -=128 ; + } +out8 (RTC_PORT_MC146818 + ofs, reg); +out8 (RTC_PORT_MC146818 + ofs +1 , val); +#endif +} + +u32 rtc_read32 (int reg) { -out8 (RTC_PORT_MC146818 ,reg); -return in8 (RTC_PORT_MC146818 +1 ); +u32 value =0 ; +int i; + +for (i =0 ; i <sizeof (value); i++) + value |=rtc_read8 (reg + i) << (i <<3 ); + +return value; } -static void rtc_write (uchar reg,uchar val) +void rtc_write32 (int reg,u32 value) { -out8 (RTC_PORT_MC146818 ,reg); -out8 (RTC_PORT_MC146818 +1 , val); +int i; + +for (i =0 ; i <sizeof (value); i++) +rtc_write8 (reg + i, (value >> (i <<3 )) &0xff ); } -#endif void rtc_init (void ) {#if CLEAR_CMOS int i; -rtc_write (RTC_SECONDS_ALARM ,0 ); -rtc_write (RTC_MINUTES_ALARM ,0 ); -rtc_write (RTC_HOURS_ALARM ,0 ); +rtc_write8 (RTC_SECONDS_ALARM ,0 ); +rtc_write8 (RTC_MINUTES_ALARM ,0 ); +rtc_write8 (RTC_HOURS_ALARM ,0 );for (i =RTC_CONFIG_A ; i <RTC_REG_SIZE ; i++) -rtc_write (i,0 ); +rtc_write8 (i,0 );printf ("RTC: zeroing CMOS RAM\n" );#endif /* Setup the real time clock */ -rtc_write (RTC_CONFIG_B ,RTC_CONFIG_B_24H ); +rtc_write8 (RTC_CONFIG_B ,RTC_CONFIG_B_24H );/* Setup the frequency it operates@*/ -rtc_write (RTC_CONFIG_A ,RTC_CONFIG_A_REF_CLCK_32KHZ | +rtc_write8 (RTC_CONFIG_A ,RTC_CONFIG_A_REF_CLCK_32KHZ |RTC_CONFIG_A_RATE_1024HZ );/* Ensure all reserved bits are 0 in register D */ -rtc_write (RTC_CONFIG_D ,RTC_CONFIG_D_VALID_RAM_AND_TIME ); +rtc_write8 (RTC_CONFIG_D ,RTC_CONFIG_D_VALID_RAM_AND_TIME );/* Clear any pending interrupts */ -rtc_read (RTC_CONFIG_C ); +rtc_read8 (RTC_CONFIG_C ); }#endif
include/rtc.h +32 -0
@@ -51,6 +51,38 @@ unsigned long mktime (unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);/** +* rtc_read8() - Read an 8-bit register +* +* @reg: Register to read +* @return value read +*/ +int rtc_read8 (int reg); + +/** +* rtc_write8() - Write an 8-bit register +* +* @reg: Register to write +* @value: Value to write +*/ +void rtc_write8 (int reg,uchar val); + +/** +* rtc_read32() - Read a 32-bit value from the RTC +* +* @reg: Offset to start reading from +* @return value read +*/ +u32 rtc_read32 (int reg); + +/** +* rtc_write32() - Write a 32-bit value to the RTC +* +* @reg: Register to start writing to +* @value: Value to write +*/ +void rtc_write32 (int reg,u32 value); + +/** * rtc_init() - Set up the real time clock ready for use */ void rtc_init (void );
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 5/12 x86: rtc: mc146818: Add helpers to read/write CMOS RAM
Quoted 9 lines · Simon Glass
On x86 we use CMOS RAM to read and write some settings. Add basic support for this, including access to registers 128-255.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Adjust functions to remain compatible with other RTC drivers
Quoted 6 lines
Changes in v2:
- Adjust the mc146818 driver instead of adding a newcmos.hheaderdrivers/rtc/mc146818.c | 121 +++++++++++++++++++++++++++++-------------------- include/rtc.h | 32 +++++++++++++ 2 files changed, 105 insertions(+), 48 deletions(-)
Applied to u-boot-x86.
PATCH v3 6/12 x86: spi: Add device tree support
In reply to Simon GlassAs a temporary measure before the ICH driver moves over to driver model, add device tree support to the driver.
---
Changes in v3: None
Changes in v2: None
drivers/spi/ich.c | 7 +++++++ include/configs/x86-common.h | 1 + 2 files changed, 8 insertions(+)
drivers/spi/ich.c +7 -0
@@ -153,6 +153,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,return &ich->slave; } +struct spi_slave *spi_setup_slave_fdt (const void *blob,int slave_node, +int spi_node) +{ +/* We only support a single SPI at present */ +return spi_setup_slave (0 ,0 ,20000000 ,0 ); +} +void spi_free_slave (struct spi_slave *slave) {struct ich_spi_slave *ich =to_ich_spi (slave);
include/configs/x86-common.h +1 -0
@@ -211,6 +211,7 @@#define CONFIG_CMD_SF_TEST #define CONFIG_CMD_SPI #define CONFIG_SPI +#define CONFIG_OF_SPI_FLASH /*----------------------------------------------------------------------- * Environment configuration
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 6/12 x86: spi: Add device tree support
Quoted 4 lines · Simon Glass
As a temporary measure before the ICH driver moves over to driver model, add device tree support to the driver.
Signed-off-by Simon Glass <[email protected]>
Quoted 8 lines
---
Changes in v3: None
Changes in v2: Nonedrivers/spi/ich.c | 7 +++++++ include/configs/x86-common.h | 1 + 2 files changed, 8 insertions(+)
Applied to u-boot-x86.
PATCH v3 7/12 Allow architecture-specific memory reservation
In reply to Simon GlassAll memory to be reserved for use after relocation by adding a new call to perform this reservation.
---
Changes in v3: None
Changes in v2: None
common/board_f.c | 7 +++++++ 1 file changed, 7 insertions(+)
common/board_f.c +7 -0
@@ -807,6 +807,12 @@ static int initf_dm(void)return 0 ; } +/* Architecture-specific memory reservation */ +__weak int reserve_arch (void ) +{ +return 0 ; +} + static init_fnc_t init_sequence_f[] = {#ifdef CONFIG_SANDBOX setup_ram_buf,
@@ -970,6 +976,7 @@ static init_fnc_t init_sequence_f[] = { setup_machine, reserve_global_data, reserve_fdt, + reserve_arch, reserve_stacks, setup_dram_config, show_dram_config,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 7/12 Allow architecture-specific memory reservation
Quoted 11 lines · Simon Glass
All memory to be reserved for use after relocation by adding a new call to perform this reservation.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3: None
Changes in v2: Nonecommon/board_f.c | 7 +++++++ 1 file changed, 7 insertions(+)
Applied to u-boot-x86.
PATCH v3 8/12 x86: dts: Add SPI flash MRC details for chromebook_link
In reply to Simon GlassCorrect the SPI flash compatible string, add an alias and specify the position of the MRC cache, used to store SDRAM training settings for the Memory Reference Code.
---
Changes in v3:
- Drop accidental creation of link.dts due to bad rebase
Changes in v2:
- Make changes to chromebook_link.dts since link.dts is gone
- Use intel,ich-spi as the compatible string
arch/x86/dts/chromebook_link.dts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/x86/dts/chromebook_link.dts +14 -1
@@ -7,6 +7,10 @@ model = "Google Link"; compatible = "google,link", "intel,celeron-ivybridge"; + aliases { + spi0 = "/spi"; + }; + config { silent_console = <0>; };
@@ -150,11 +154,20 @@ spi { #address-cells = <1>; #size-cells = <0>; - compatible = "intel,ich9"; + compatible = "intel,ich-spi"; spi-flash at 0 { + #size-cells = <1>; + #address-cells = <1>; reg = <0>; compatible = "winbond,w25q64", "spi-flash"; memory-map = <0xff800000 0x00800000>; + rw-mrc-cache { + label = "rw-mrc-cache"; + /* Alignment: 4k (for updating) */ + reg = <0x003e0000 0x00010000>; + type = "wiped"; + wipe-value = [ff]; + }; }; };
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 8/12 x86: dts: Add SPI flash MRC details for chromebook_link
Quoted 10 lines · Simon Glass
Correct the SPI flash compatible string, add an alias and specify the position of the MRC cache, used to store SDRAM training settings for the Memory Reference Code.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Drop accidental creation oflink.dtsdue to bad rebase
Quoted 6 lines
Changes in v2:
- Make changes tochromebook_link.dtssincelink.dtsis gone
- Use intel,ich-spi as the compatible stringarch/x86/dts/chromebook_link.dts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Applied to u-boot-x86.
PATCH v3 9/12 x86: Implement a cache for Memory Reference Code parameters
In reply to Simon GlassThe memory reference code takes a very long time to 'train' its SDRAM interface, around half a second. To avoid this delay on every boot we can store the parameters from the last training sessions to speed up the next.
Add an implementation of this, storing the training data in CMOS RAM and SPI flash.
---
Changes in v3:
- Use checksum code from net/checksum.c
Changes in v2:
- Update for the new CMOS RAM access functions in the RTC
- Add a comment about why both CMOS RAM and SPI flash are used for the cache
arch/x86/cpu/ivybridge/Makefile | 1 + arch/x86/cpu/ivybridge/mrccache.c | 156 +++++++++++++++ arch/x86/cpu/ivybridge/sdram.c | 253 +++++++++++++++++++++++++ arch/x86/include/asm/arch-ivybridge/mrccache.h | 51 +++++ arch/x86/include/asm/global_data.h | 3 + 5 files changed, 464 insertions(+) create mode 100644 arch/x86/cpu/ivybridge/mrccache.c create mode 100644 arch/x86/include/asm/arch-ivybridge/mrccache.h
arch/x86/cpu/ivybridge/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-y += lpc.o obj-y += me_status.o obj-y += model_206ax.o obj-y += microcode_intel.o +obj-y += mrccache.o obj-y += northbridge.o obj-y += pch.o obj-y += pci.o
arch/x86/cpu/ivybridge/mrccache.c new file +156 -0
156 lines not on this page · raw message
arch/x86/cpu/ivybridge/sdram.c +253 -0
301 lines not on this page · raw message
arch/x86/include/asm/arch-ivybridge/mrccache.h new file +51 -0
51 lines not on this page · raw message
arch/x86/include/asm/global_data.h +3 -0
@@ -64,6 +64,9 @@ struct arch_global_data {#endif struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS ];int mtrr_req_count; +/* MRC training data to save for the next boot */ +char *mrc_output; + unsigned int mrc_output_len; };#endif
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 9/12 x86: Implement a cache for Memory Reference Code parameters
Quoted 17 lines · Simon Glass
The memory reference code takes a very long time to 'train' its SDRAM interface, around half a second. To avoid this delay on every boot we can store the parameters from the last training sessions to speed up the next.
Add an implementation of this, storing the training data in CMOS RAM and SPI flash.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Use checksum code fromnet/checksum.cChanges in v2:
- Update for the new CMOS RAM access functions in the RTC
- Add a comment about why both CMOS RAM and SPI flash are used for the cache
Quoted 8 lines
arch/x86/cpu/ivybridge/Makefile | 1 + arch/x86/cpu/ivybridge/mrccache.c | 156 +++++++++++++++ arch/x86/cpu/ivybridge/sdram.c | 253 +++++++++++++++++++++++++ arch/x86/include/asm/arch-ivybridge/mrccache.h | 51 +++++ arch/x86/include/asm/global_data.h | 3 + 5 files changed, 464 insertions(+) create mode 100644 arch/x86/cpu/ivybridge/mrccache.c create mode 100644 arch/x86/include/asm/arch-ivybridge/mrccache.h
Applied to u-boot-x86.
PATCH v3 10/12 x86: config: Enable hook for saving MRC configuration
In reply to Simon GlassAdd a hook to ensure that this information is saved.
---
Changes in v3:
- Add misc_init_r() call for link now that it is shared with chromebook_link
Changes in v2: None
arch/x86/cpu/coreboot/coreboot.c | 5 +++++ include/configs/chromebook_link.h | 1 + 2 files changed, 6 insertions(+)
arch/x86/cpu/coreboot/coreboot.c +5 -0
@@ -99,3 +99,8 @@ void panic_puts(const char *str)while (*str)NS16550_putc (port, *str++); } + +int misc_init_r (void ) +{ +return 0 ; +}
include/configs/chromebook_link.h +1 -0
@@ -20,6 +20,7 @@#define CONFIG_DCACHE_RAM_MRC_VAR_SIZE 0x4000#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MISC_INIT_R #define CONFIG_NR_DRAM_BANKS 8#define CONFIG_X86_MRC_ADDR 0xfffa0000
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 10/12 x86: config: Enable hook for saving MRC configuration
Quoted 32 lines · Simon Glass
Add a hook to ensure that this information is saved.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Addmisc_init_r()call for link now that it is shared withchromebook_linkChanges in v2: None
arch/x86/cpu/coreboot/coreboot.c | 5 +++++ include/configs/chromebook_link.h | 1 + 2 files changed, 6 insertions(+)arch/x86/cpu/coreboot/coreboot.c +5
-0@@ -99,3 +99,8 @@ void panic_puts(const char *str)while (*str)NS16550_putc (port, *str++); } + +int misc_init_r (void ) +{ +return 0 ; +}include/configs/chromebook_link.h +0
-0
include/configs/chromebook_link.h
Quoted 8 lines
include/configs/chromebook_link.h +1
-1@@ -20,6 +20,7 @@#define CONFIG_DCACHE_RAM_MRC_VAR_SIZE 0x4000#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MISC_INIT_R #define CONFIG_NR_DRAM_BANKS 8#define CONFIG_X86_MRC_ADDR 0xfffa0000 --
PATCH v3 10/12 x86: config: Enable hook for saving MRC configuration
Quoted 38 lines · Bin Meng
Quoted 37 lines · Simon Glass
Add a hook to ensure that this information is saved.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Addmisc_init_r()call for link now that it is shared withchromebook_linkChanges in v2: None
arch/x86/cpu/coreboot/coreboot.c | 5 +++++ include/configs/chromebook_link.h | 1 + 2 files changed, 6 insertions(+)arch/x86/cpu/coreboot/coreboot.c +5
-0@@ -99,3 +99,8 @@ void panic_puts(const char *str)while (*str)NS16550_putc (port, *str++); } + +int misc_init_r (void ) +{ +return 0 ; +}include/configs/chromebook_link.h +1
-0@@ -20,6 +20,7 @@#define CONFIG_DCACHE_RAM_MRC_VAR_SIZE 0x4000#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_MISC_INIT_R
Quoted 5 lines
include/configs/chromebook_link.h
Quoted 3 lines
include/configs/chromebook_link.h +0
-1#define CONFIG_NR_DRAM_BANKS 8#define CONFIG_X86_MRC_ADDR 0xfffa0000 --Reviewed-by Bin Meng <[email protected]>
Applied to u-boot-x86.
PATCH v3 11/12 x86: ivybridge: Drop the Kconfig MRC cache information
In reply to Simon GlassThis is now stored in the device tree.
---
Changes in v3: None
Changes in v2: None
arch/x86/cpu/ivybridge/Kconfig | 28 ---------------------------- 1 file changed, 28 deletions(-)
arch/x86/cpu/ivybridge/Kconfig +0 -28
@@ -26,20 +26,6 @@ config CACHE_MRC_SIZE_KB int default 256 -config MRC_CACHE_BASE - hex - default 0xff800000 - -config MRC_CACHE_LOCATION - hex - depends on !CHROMEOS - default 0x1ec000 - -config MRC_CACHE_SIZE - hex - depends on !CHROMEOS - default 0x10000 - config DCACHE_RAM_BASE hex default 0xff7f0000
@@ -64,20 +50,6 @@ config CACHE_MRC_SIZE_KB int default 512 -config MRC_CACHE_BASE - hex - default 0xff800000 - -config MRC_CACHE_LOCATION - hex - depends on !CHROMEOS - default 0x370000 - -config MRC_CACHE_SIZE - hex - depends on !CHROMEOS - default 0x10000 - config DCACHE_RAM_BASE hex default 0xff7e0000
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 11/12 x86: ivybridge: Drop the Kconfig MRC cache information
Quoted 10 lines · Simon Glass
This is now stored in the device tree.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3: None
Changes in v2: Nonearch/x86/cpu/ivybridge/Kconfig | 28 ---------------------------- 1 file changed, 28 deletions(-)
Applied to u-boot-x86.
PATCH v3 12/12 x86: config: chromebook_link: Enable environment
In reply to Simon GlassEnable an environment area.
---
Changes in v3: None
Changes in v2: None
include/configs/chromebook_link.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/configs/chromebook_link.h +7 -0
@@ -64,6 +64,13 @@#define CONFIG_CMD_CROS_EC #define CONFIG_ARCH_EARLY_INIT_R +#undef CONFIG_ENV_IS_NOWHERE +#undef CONFIG_ENV_SIZE +#define CONFIG_ENV_SIZE 0x1000 +#define CONFIG_ENV_SECT_SIZE 0x1000 +#define CONFIG_ENV_IS_IN_SPI_FLASH +#define CONFIG_ENV_OFFSET 0x003f8000 +#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ "stdout=vga,serial\0" \ "stderr=vga,serial\0"
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 12/12 x86: config: chromebook_link: Enable environment
Quoted 11 lines · Simon Glass
Enable an environment area.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v3: None
Changes in v2: Noneinclude/configs/chromebook_link.h | 7 +++++++ 1 file changed, 7 insertions(+)
Applied to u-boot-x86.
v3 cover Add support for caching Memory Reference Code data
In reply to Simon GlassHi Bin,
Quoted 6 lines · Simon Glass
Since the memory reference code is so slow on x86, add a feature to bypass this, storing the previous parameters in SPI flash. This saves around 500ms on each boot.
Also enable a SPI flash environment.
Quoted 8 lines
Changes in v3:
- Add new patch to move checksum to its own file innet/
- Adjustnet/code to use the new checksum functions
- Use checksum code that is now innet/checksum.c
- Adjust functions to remain compatible with other RTC drivers
- Drop accidental creation oflink.dtsdue to bad rebase
- Use checksum code fromnet/checksum.c
- Addmisc_init_r()call for link now that it is shared withchromebook_link
I'd like to get this applied. Do you have any comments on the new checksum approach?
I will need to get an Ack from Joe before I apply the net/ patch (which changes over to the new function). But the rest can come through the x86 tree.
Regards,
Simon
v3 cover Add support for caching Memory Reference Code data
Hi Simon,
Quoted 18 lines · Simon Glass
Hi Bin,
Quoted 6 lines · Simon Glass
Since the memory reference code is so slow on x86, add a feature to bypass this, storing the previous parameters in SPI flash. This saves around 500ms on each boot.
Also enable a SPI flash environment.
Quoted 8 lines
Changes in v3:
- Add new patch to move checksum to its own file innet/
- Adjustnet/code to use the new checksum functions
- Use checksum code that is now innet/checksum.c
- Adjust functions to remain compatible with other RTC drivers
- Drop accidental creation oflink.dtsdue to bad rebase
- Use checksum code fromnet/checksum.c
- Addmisc_init_r()call for link now that it is shared withchromebook_link
Quoted 3 lines
I'd like to get this applied. Do you have any comments on the new checksum approach?
I did not perform a thorough review to the new checksum thus did not offer a 'Reviewed-by', but generally it looks good to me. Please go ahead.
Quoted 4 lines
I will need to get an Ack from Joe before I apply the
net/patch (which changes over to the new function). But the rest can come through the x86 tree.
Regards,
Bin
v3 cover Add support for caching Memory Reference Code data
Quoted 21 lines · Bin Meng
Hi Simon,
Quoted 18 lines · Simon Glass
Hi Bin,
Quoted 14 lines · Simon Glass
Since the memory reference code is so slow on x86, add a feature to bypass this, storing the previous parameters in SPI flash. This saves around 500ms on each boot.
Also enable a SPI flash environment.
Changes in v3:
- Add new patch to move checksum to its own file innet/
- Adjustnet/code to use the new checksum functions
- Use checksum code that is now innet/checksum.c
- Adjust functions to remain compatible with other RTC drivers
- Drop accidental creation oflink.dtsdue to bad rebase
- Use checksum code fromnet/checksum.c
- Addmisc_init_r()call for link now that it is shared withchromebook_link
Quoted 7 lines
Quoted 3 lines
I'd like to get this applied. Do you have any comments on the new checksum approach?
I did not perform a thorough review to the new checksum thus did not offer a 'Reviewed-by', but generally it looks good to me. Please go ahead.
OK, going ahead, thanks.
I'll leave out the net/ patch until I get some word on that.