Changeset 1452 for trunk


Ignore:
Timestamp:
10/20/11 14:57:14 (7 months ago)
Author:
stefanct
Message:

ichspi: add (partially) dead support code for Intel Hardware Sequencing

This was done to ease the review. Another patch will hook up (and
explain) this code later.

Signed-off-by: Stefan Tauner <stefan.tauner@…>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ich_descriptors.c

    r1443 r1452  
    214214} 
    215215 
     216/** Returns the integer representation of the component density with index 
     217idx in bytes or 0 if a correct size can not be determined. */ 
     218int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx) 
     219{ 
     220        uint8_t size_enc; 
     221         
     222        switch(idx) { 
     223        case 0: 
     224                size_enc = desc->component.comp1_density; 
     225                break; 
     226        case 1: 
     227                if (desc->content.NC == 0) 
     228                        return 0; 
     229                size_enc = desc->component.comp2_density; 
     230                break; 
     231        default: 
     232                msg_perr("Only ICH SPI component index 0 or 1 are supported " 
     233                         "yet.\n"); 
     234                return 0; 
     235        } 
     236        if (size_enc > 5) { 
     237                msg_perr("Density of ICH SPI component with index %d is " 
     238                         "invalid. Encoded density is 0x%x.\n", idx, size_enc); 
     239                return 0; 
     240        } 
     241        return (1 << (19 + size_enc)); 
     242} 
     243 
    216244static uint32_t read_descriptor_reg(uint8_t section, uint16_t offset, void *spibar) 
    217245{ 
  • trunk/ich_descriptors.h

    r1443 r1452  
    256256 
    257257int read_ich_descriptors_via_fdo(void *spibar, struct ich_descriptors *desc); 
     258int getFCBA_component_density(const struct ich_descriptors *desc, uint8_t idx); 
    258259 
    259260#endif /* __ICH_DESCRIPTORS_H__ */ 
  • trunk/ichspi.c

    r1449 r1452  
    2727 
    2828#include <string.h> 
     29#include <stdlib.h> 
    2930#include "flash.h" 
    3031#include "programmer.h" 
     
    10801081        return result; 
    10811082} 
     1083 
     1084#if 0 
     1085/* Sets FLA in FADDR to (addr & 0x01FFFFFF) without touching other bits. */ 
     1086static void ich_hwseq_set_addr(uint32_t addr) 
     1087{ 
     1088        uint32_t addr_old = REGREAD32(ICH9_REG_FADDR) & ~0x01FFFFFF; 
     1089        REGWRITE32(ICH9_REG_FADDR, (addr & 0x01FFFFFF) | addr_old); 
     1090} 
     1091 
     1092/* Sets FADDR.FLA to 'addr' and returns the erase block size in bytes 
     1093 * of the block containing this address. May return nonsense if the address is 
     1094 * not valid. The erase block size for a specific address depends on the flash 
     1095 * partition layout as specified by FPB and the partition properties as defined 
     1096 * by UVSCC and LVSCC respectively. An alternative to implement this method 
     1097 * would be by querying FPB and the respective VSCC register directly. 
     1098 */ 
     1099static uint32_t ich_hwseq_get_erase_block_size(unsigned int addr) 
     1100{ 
     1101        uint8_t enc_berase; 
     1102        static const uint32_t const dec_berase[4] = { 
     1103                256, 
     1104                4 * 1024, 
     1105                8 * 1024, 
     1106                64 * 1024 
     1107        }; 
     1108 
     1109        ich_hwseq_set_addr(addr); 
     1110        enc_berase = (REGREAD16(ICH9_REG_HSFS) & HSFS_BERASE) >> 
     1111                     HSFS_BERASE_OFF; 
     1112        return dec_berase[enc_berase]; 
     1113} 
     1114 
     1115/* Polls for Cycle Done Status, Flash Cycle Error or timeout in 8 us intervals. 
     1116   Resets all error flags in HSFS. 
     1117   Returns 0 if the cycle completes successfully without errors within 
     1118   timeout us, 1 on errors. */ 
     1119static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout, 
     1120                                             unsigned int len) 
     1121{ 
     1122        uint16_t hsfs; 
     1123        uint32_t addr; 
     1124 
     1125        timeout /= 8; /* scale timeout duration to counter */ 
     1126        while ((((hsfs = REGREAD16(ICH9_REG_HSFS)) & 
     1127                 (HSFS_FDONE | HSFS_FCERR)) == 0) && 
     1128               --timeout) { 
     1129                programmer_delay(8); 
     1130        } 
     1131        REGWRITE16(ICH9_REG_HSFS, REGREAD16(ICH9_REG_HSFS)); 
     1132        if (!timeout) { 
     1133                addr = REGREAD32(ICH9_REG_FADDR) & 0x01FFFFFF; 
     1134                msg_perr("Timeout error between offset 0x%08x and " 
     1135                         "0x%08x + %d (=0x%08x)!\n", 
     1136                         addr, addr, len - 1, addr + len - 1); 
     1137                prettyprint_ich9_reg_hsfs(hsfs); 
     1138                prettyprint_ich9_reg_hsfc(REGREAD16(ICH9_REG_HSFC)); 
     1139                return 1; 
     1140        } 
     1141 
     1142        if (hsfs & HSFS_FCERR) { 
     1143                addr = REGREAD32(ICH9_REG_FADDR) & 0x01FFFFFF; 
     1144                msg_perr("Transaction error between offset 0x%08x and " 
     1145                         "0x%08x (=0x%08x + %d)!\n", 
     1146                         addr, addr + len - 1, addr, len - 1); 
     1147                prettyprint_ich9_reg_hsfs(hsfs); 
     1148                prettyprint_ich9_reg_hsfc(REGREAD16(ICH9_REG_HSFC)); 
     1149                return 1; 
     1150        } 
     1151        return 0; 
     1152} 
     1153#endif 
    10821154 
    10831155static int ich_spi_send_multicommand(struct spi_command *cmds) 
     
    12511323        uint16_t spibar_offset, tmp2; 
    12521324        uint32_t tmp; 
    1253         int ichspi_desc = 0; 
     1325        int desc_valid = 0; 
    12541326 
    12551327        switch (ich_generation) { 
    12561328        case 7: 
    1257                 register_spi_programmer(&spi_programmer_ich7); 
    12581329                spibar_offset = 0x3020; 
    12591330                break; 
    12601331        case 8: 
    1261                 register_spi_programmer(&spi_programmer_ich9); 
    12621332                spibar_offset = 0x3020; 
    12631333                break; 
     
    12651335        case 10: 
    12661336        default:                /* Future version might behave the same */ 
    1267                 register_spi_programmer(&spi_programmer_ich9); 
    12681337                spibar_offset = 0x3800; 
    12691338                break; 
     
    12761345        ich_spibar = rcrb + spibar_offset; 
    12771346 
    1278         switch (spi_programmer->type) { 
    1279         case SPI_CONTROLLER_ICH7: 
     1347        switch (ich_generation) { 
     1348        case 7: 
    12801349                msg_pdbg("0x00: 0x%04x     (SPIS)\n", 
    12811350                             mmio_readw(ich_spibar + 0)); 
     
    13141383                } 
    13151384                ich_set_bbar(ich_generation, 0); 
     1385                register_spi_programmer(&spi_programmer_ich7); 
    13161386                ich_init_opcodes(); 
    13171387                break; 
    1318         case SPI_CONTROLLER_ICH9: 
     1388        case 8: 
     1389        case 9: 
     1390        case 10: 
     1391        default:                /* Future version might behave the same */ 
    13191392                tmp2 = mmio_readw(ich_spibar + ICH9_REG_HSFS); 
    13201393                msg_pdbg("0x04: 0x%04x (HSFS)\n", tmp2); 
     
    13251398                } 
    13261399                if (tmp2 & HSFS_FDV) 
    1327                         ichspi_desc = 1; 
    1328                 if (!(tmp2 & HSFS_FDOPSS) && ichspi_desc) 
     1400                        desc_valid = 1; 
     1401                if (!(tmp2 & HSFS_FDOPSS) && desc_valid) 
    13291402                        msg_pinfo("The Flash Descriptor Security Override " 
    13301403                                  "Strap-Pin is set. Restrictions implied\n" 
     
    14011474 
    14021475                msg_pdbg("\n"); 
    1403                 if (ichspi_desc) { 
     1476                if (desc_valid) { 
    14041477                        struct ich_descriptors desc = {{ 0 }}; 
    14051478                        if (read_ich_descriptors_via_fdo(ich_spibar, &desc) == 
     
    14081481                                                            &desc); 
    14091482                } 
     1483                register_spi_programmer(&spi_programmer_ich9); 
    14101484                ich_init_opcodes(); 
    1411                 break; 
    1412         default: 
    1413                 /* Nothing */ 
    14141485                break; 
    14151486        } 
Note: See TracChangeset for help on using the changeset viewer.