Changeset 5097


Ignore:
Timestamp:
Feb 9, 2010 11:22:33 AM (3 years ago)
Author:
oxygene
Message:

Port of CS5536 early UART setup from v3.
Permit early setup of COM2

Signed-off-by: Edwin Beasant <edwin_beasant@…>
Acked-by: Patrick Georgi <patrick.georgi@…>

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainboard/amd/norwich/romstage.c

    r5092 r5097  
    116116         */ 
    117117        /* If debug. real setup done in chipset init via Config.lb. */ 
    118         cs5536_setup_onchipuart(); 
     118        cs5536_setup_onchipuart(1); 
    119119        mb_gpio_init(); 
    120120        uart_init(); 
  • trunk/src/mainboard/olpc/btest/romstage.c

    r5092 r5097  
    178178         * for cs5536 
    179179         */ 
    180         cs5536_setup_onchipuart(); 
     180        cs5536_setup_onchipuart(1); 
    181181        gpio_init(); 
    182182        uart_init(); 
  • trunk/src/mainboard/olpc/rev_a/romstage.c

    r5092 r5097  
    178178         * for cs5536 
    179179         */ 
    180         cs5536_setup_onchipuart(); 
     180        cs5536_setup_onchipuart(1); 
    181181        gpio_init(); 
    182182        uart_init(); 
  • trunk/src/southbridge/amd/cs5536/cs5536.c

    r5074 r5097  
    248248        isa_dma_init(); 
    249249} 
    250  
     250                         
     251 
     252/** 
     253 * Depending on settings in the config struct, enable COM1 or COM2 or both. 
     254 * 
     255 * If the enable is NOT set, the UARTs are explicitly disabled, which is 
     256 * required if (e.g.) there is a Super I/O attached that does COM1 or COM2. 
     257 * 
     258 * @param sb Southbridge config structure. 
     259 */ 
    251260static void uarts_init(struct southbridge_amd_cs5536_config *sb) 
    252261{ 
    253262        msr_t msr; 
    254         uint16_t addr; 
    255         uint32_t gpio_addr; 
     263        u16 addr = 0; 
     264        u32 gpio_addr; 
    256265        device_t dev; 
    257  
     266         
    258267        dev = dev_find_device(PCI_VENDOR_ID_AMD,  
    259268                        PCI_DEVICE_ID_AMD_CS5536_ISA, 0); 
    260269        gpio_addr = pci_read_config32(dev, PCI_BASE_ADDRESS_1); 
    261         gpio_addr &= ~1;        /* clear IO bit */ 
    262         printk_debug("GPIO_ADDR: %08X\n", gpio_addr); 
    263  
    264         /* This could be extended to support IR modes */ 
     270        gpio_addr &= ~1;        /* Clear I/O bit */ 
     271        printk(BIOS_DEBUG, "GPIO_ADDR: %08X\n", gpio_addr); 
     272 
     273        /* This could be extended to support IR modes. */ 
    265274 
    266275        /* COM1 */ 
    267276        if (sb->com1_enable) { 
    268                 /* Set the address */ 
     277                printk(BIOS_SPEW, "uarts_init: enable COM1\n"); 
     278                /* Set the address. */ 
    269279                switch (sb->com1_address) { 
    270280                case 0x3F8: 
    271281                        addr = 7; 
    272282                        break; 
    273  
    274283                case 0x3E8: 
    275284                        addr = 6; 
    276285                        break; 
    277  
    278286                case 0x2F8: 
    279287                        addr = 5; 
    280288                        break; 
    281  
    282289                case 0x2E8: 
    283290                        addr = 4; 
     
    288295                wrmsr(MDD_LEG_IO, msr); 
    289296 
    290                 /* Set the IRQ */ 
     297                /* Set the IRQ. */ 
    291298                msr = rdmsr(MDD_IRQM_YHIGH); 
    292299                msr.lo |= sb->com1_irq << 24; 
     
    294301 
    295302                /* GPIO8 - UART1_TX */ 
    296                 /* Set: Output Enable  (0x4) */ 
     303                /* Set: Output Enable (0x4) */ 
    297304                outl(GPIOL_8_SET, gpio_addr + GPIOL_OUTPUT_ENABLE); 
    298305                /* Set: OUTAUX1 Select (0x10) */ 
     
    302309                /* Set: Input Enable   (0x20) */ 
    303310                outl(GPIOL_9_SET, gpio_addr + GPIOL_INPUT_ENABLE); 
    304                 /* Set: INAUX1 Select  (0x34) */ 
     311                /* Set: INAUX1 Select (0x34) */ 
    305312                outl(GPIOL_9_SET, gpio_addr + GPIOL_IN_AUX1_SELECT); 
    306313 
    307                 /* Set: GPIO 8 + 9 Pull Up         (0x18) */ 
     314                /* Set: GPIO 8 + 9 Pull Up (0x18) */ 
    308315                outl(GPIOL_8_SET | GPIOL_9_SET, 
    309316                     gpio_addr + GPIOL_PULLUP_ENABLE); 
    310317 
    311                 /* enable COM1 */ 
    312                 /* Bit 1 = device enable Bit 4 = allow access to the upper banks */ 
     318                /* Enable COM1. 
     319                 * 
     320                 * Bit 1 = device enable 
     321                 * Bit 4 = allow access to the upper banks 
     322                 */ 
    313323                msr.lo = (1 << 4) | (1 << 1); 
    314324                msr.hi = 0; 
    315325                wrmsr(MDD_UART1_CONF, msr); 
    316  
    317326        } else { 
    318                 /* Reset and disable COM1 */ 
     327                /* Reset and disable COM1. */ 
     328                printk(BIOS_SPEW, "uarts_init: disable COM1\n"); 
    319329                msr = rdmsr(MDD_UART1_CONF); 
    320                 msr.lo = 1;     // reset 
     330                msr.lo = 1;                     /* Reset */ 
    321331                wrmsr(MDD_UART1_CONF, msr); 
    322                 msr.lo = 0;     // disabled 
     332                msr.lo = 0;                     /* Disabled */ 
    323333                wrmsr(MDD_UART1_CONF, msr); 
    324334 
    325                 /* Disable the IRQ */ 
     335                /* Disable the IRQ. */ 
    326336                msr = rdmsr(MDD_LEG_IO); 
    327337                msr.lo &= ~(0xF << 16); 
     
    331341        /* COM2 */ 
    332342        if (sb->com2_enable) { 
     343                printk(BIOS_SPEW, "uarts_init: enable COM2\n"); 
    333344                switch (sb->com2_address) { 
    334345                case 0x3F8: 
    335346                        addr = 7; 
    336347                        break; 
    337  
    338348                case 0x3E8: 
    339349                        addr = 6; 
    340350                        break; 
    341  
    342351                case 0x2F8: 
    343352                        addr = 5; 
    344353                        break; 
    345  
    346354                case 0x2E8: 
    347355                        addr = 4; 
     
    351359                msr.lo |= addr << 20; 
    352360                wrmsr(MDD_LEG_IO, msr); 
    353  
    354                 /* Set the IRQ */ 
     361                printk(BIOS_SPEW, "uarts_init: wrote COM2 address 0x%x\n", sb->com2_address); 
     362 
     363                /* Set the IRQ. */ 
    355364                msr = rdmsr(MDD_IRQM_YHIGH); 
    356365                msr.lo |= sb->com2_irq << 28; 
    357366                wrmsr(MDD_IRQM_YHIGH, msr); 
     367                printk(BIOS_SPEW, "uarts_init: set COM2 irq\n"); 
    358368 
    359369                /* GPIO3 - UART2_RX */ 
     
    366376                /* Set: Output Enable (0x4) */ 
    367377                outl(GPIOL_4_SET, gpio_addr + GPIOL_OUTPUT_ENABLE); 
     378                printk(BIOS_SPEW, "uarts_init: set output enable\n"); 
    368379                /* Set: OUTAUX1 Select (0x10) */ 
    369380                outl(GPIOL_4_SET, gpio_addr + GPIOL_OUT_AUX1_SELECT); 
    370  
    371                 /* Set: GPIO 3 and 4 Pull Up (0x18) */ 
     381                printk(BIOS_SPEW, "uarts_init: set OUTAUX1\n"); 
     382 
     383                /* Set: GPIO 3 + 4 Pull Up (0x18) */ 
    372384                outl(GPIOL_3_SET | GPIOL_4_SET, 
    373385                     gpio_addr + GPIOL_PULLUP_ENABLE); 
    374  
    375                 /* enable COM2 */ 
    376                 /* Bit 1 = device enable Bit 4 = allow access to the upper banks */ 
     386                printk(BIOS_SPEW, "uarts_init: set pullup COM2\n"); 
     387 
     388                /* Enable COM2. 
     389                 * 
     390                 * Bit 1 = device enable 
     391                 * Bit 4 = allow access to the upper banks 
     392                 */ 
    377393                msr.lo = (1 << 4) | (1 << 1); 
    378394                msr.hi = 0; 
    379395                wrmsr(MDD_UART2_CONF, msr); 
    380  
     396                printk(BIOS_SPEW, "uarts_init: COM2 enabled\n"); 
    381397        } else { 
    382                 /* Reset and disable COM2 */ 
     398                printk(BIOS_SPEW, "uarts_init: disable COM2\n"); 
     399                /* Reset and disable COM2. */ 
    383400                msr = rdmsr(MDD_UART2_CONF); 
    384                 msr.lo = 1;     // reset 
     401                msr.lo = 1;                     /* Reset */ 
    385402                wrmsr(MDD_UART2_CONF, msr); 
    386                 msr.lo = 0;     // disabled 
     403                msr.lo = 0;                     /* Disabled */ 
    387404                wrmsr(MDD_UART2_CONF, msr); 
    388405 
    389                 /* Disable the IRQ */ 
     406                /* Disable the IRQ. */ 
    390407                msr = rdmsr(MDD_LEG_IO); 
    391408                msr.lo &= ~(0xF << 20); 
     
    393410        } 
    394411} 
     412 
    395413 
    396414#define HCCPARAMS               0x08 
  • trunk/src/southbridge/amd/cs5536/cs5536_early_setup.c

    r5074 r5097  
    154154} 
    155155 
    156 /* see page 412 of the cs5536 companion book */ 
    157 static void cs5536_setup_onchipuart(void) 
     156/** 
     157 * Enable the on-chip UART. 
     158 * 
     159 * See page 412 of the AMD Geode CS5536 Companion Device data book. 
     160 */ 
     161void cs5536_setup_onchipuart1(void) 
    158162{ 
    159163        msr_t msr; 
    160164 
    161165        /* Setup early for polling only mode. 
    162          * 1. Eanble GPIO 8 to OUT_AUX1, 9 to IN_AUX1 
     166         * 1. Enable GPIO 8 to OUT_AUX1, 9 to IN_AUX1. 
    163167         *        GPIO LBAR + 0x04, LBAR + 0x10, LBAR + 0x20, LBAR + 34 
    164          * 2. Enable UART IO space in MDD 
     168         * 2. Enable UART I/O space in MDD. 
    165169         *        MSR 0x51400014 bit 18:16 
    166          * 3. Enable UART controller 
     170         * 3. Enable UART controller. 
    167171         *        MSR 0x5140003A bit 0, 1 
    168172         */ 
    169173 
    170174        /* GPIO8 - UART1_TX */ 
    171         /* Set: Output Enable  (0x4) */ 
     175        /* Set: Output Enable (0x4) */ 
    172176        outl(GPIOL_8_SET, GPIO_IO_BASE + GPIOL_OUTPUT_ENABLE); 
    173177        /* Set: OUTAUX1 Select (0x10) */ 
     
    175179 
    176180        /* GPIO9 - UART1_RX */ 
    177         /* Set: Input Enable   (0x20) */ 
     181        /* Set: Input Enable (0x20) */ 
    178182        outl(GPIOL_9_SET, GPIO_IO_BASE + GPIOL_INPUT_ENABLE); 
    179         /* Set: INAUX1 Select  (0x34) */ 
     183        /* Set: INAUX1 Select (0x34) */ 
    180184        outl(GPIOL_9_SET, GPIO_IO_BASE + GPIOL_IN_AUX1_SELECT); 
    181185 
    182         /* set address to 3F8 */ 
     186        /* Set address to 0x3F8. */ 
    183187        msr = rdmsr(MDD_LEG_IO); 
    184188        msr.lo |= 0x7 << 16; 
    185189        wrmsr(MDD_LEG_IO, msr); 
    186190 
    187         /*      Bit 1 = DEVEN (device enable) 
    188          *      Bit 4 = EN_BANKS (allow access to the upper banks 
     191        /* Bit 1 = DEVEN (device enable) 
     192         * Bit 4 = EN_BANKS (allow access to the upper banks) 
    189193         */ 
    190194        msr.lo = (1 << 4) | (1 << 1); 
    191195        msr.hi = 0; 
    192196 
    193         /* enable COM1 */ 
     197        /* Enable COM1. */ 
    194198        wrmsr(MDD_UART1_CONF, msr); 
    195199} 
     200 
     201void cs5536_setup_onchipuart2(void) 
     202{ 
     203        msr_t msr; 
     204 
     205        /* GPIO4 - UART2_TX */ 
     206        /* Set: Output Enable  (0x4) */ 
     207        outl(GPIOL_4_SET, GPIO_IO_BASE + GPIOL_OUTPUT_ENABLE); 
     208        /* Set: OUTAUX1 Select (0x10) */ 
     209        outl(GPIOL_4_SET, GPIO_IO_BASE + GPIOL_OUT_AUX1_SELECT); 
     210        /* GPIO4 - UART2_RX */ 
     211        /* Set: Input Enable   (0x20) */ 
     212        outl(GPIOL_3_SET, GPIO_IO_BASE + GPIOL_INPUT_ENABLE); 
     213        /* Set: INAUX1 Select  (0x34) */ 
     214        outl(GPIOL_3_SET, GPIO_IO_BASE + GPIOL_IN_AUX1_SELECT); 
     215 
     216        /* Set: GPIO 3 + 3 Pull Up  (0x18) */ 
     217        outl(GPIOL_3_SET | GPIOL_4_SET, 
     218             GPIO_IO_BASE + GPIOL_PULLUP_ENABLE); 
     219 
     220        /* set address to 2F8 */ 
     221        msr = rdmsr(MDD_LEG_IO); 
     222        msr.lo |= 0x5 << 20; 
     223        wrmsr(MDD_LEG_IO, msr); 
     224 
     225        /* Bit 1 = DEVEN (device enable) 
     226         * Bit 4 = EN_BANKS (allow access to the upper banks 
     227         */ 
     228        msr.lo = (1 << 4) | (1 << 1); 
     229        msr.hi = 0; 
     230 
     231        /* enable COM2 */ 
     232        wrmsr(MDD_UART2_CONF, msr); 
     233} 
     234 
     235void cs5536_setup_onchipuart(int uart) 
     236{ 
     237        switch (uart) { 
     238        case 1: 
     239                cs5536_setup_onchipuart1(); 
     240                break; 
     241        case 2: 
     242                cs5536_setup_onchipuart2(); 
     243                break; 
     244        } 
     245} 
     246 
    196247 
    197248/* note: you can't do prints in here in most cases, 
Note: See TracChangeset for help on using the changeset viewer.